﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Content;

namespace Labb2
{
    class SmokeSystem
    {
        private Texture2D m_smokeTexture;
        private Vector2 m_startingPosition;
        private int m_numberOfSmoke;

        Camera m_camera;
        SmokeParticle[] m_smokeArray;

        public SmokeSystem(Camera camera, Vector2 startingPosition, int numberOfSmoke) 
        {
            m_camera = camera;
            m_startingPosition = startingPosition;
            m_numberOfSmoke = numberOfSmoke;
            m_smokeArray = new SmokeParticle[m_numberOfSmoke]; 
        }

        internal void Update(GameTime gameTime) 
        {
            foreach (SmokeParticle smoke in m_smokeArray)
            {
                smoke.Update(gameTime);
            }
        }
        
        internal void Draw(SpriteBatch spritebatch) 
        {
            foreach (SmokeParticle smoke in m_smokeArray)
            {
                smoke.Draw(spritebatch);
            }
        }

        internal void LoadContent(ContentManager contManager) 
        {
            m_smokeTexture = contManager.Load<Texture2D>("particlesmoke");

            for (int i = 0; i < m_numberOfSmoke; i++) 
            {
                SmokeParticle smoke = new SmokeParticle(m_startingPosition, i, m_smokeTexture, m_camera);
                m_smokeArray[i] = smoke;
            }
        }

        internal void ResetArray()
        {
            Array.Clear(m_smokeArray, 0, m_numberOfSmoke);
        }
    }    
}
